<template>
    <van-field @click.stop="selected" :name="data.fieldName" :label="data.label">
        <template #input>
            <van-radio-group v-model="value">
                <van-radio :checked-color="data.style.checkedColor" style="margin-bottom: 8px"  v-for="(item, index) in data.options" :key="index" :name="index">{{ item.label }}</van-radio>
            </van-radio-group>
        </template>
    </van-field>
</template>

<script>
    export default {
        props: {
            data: Object,
            selected: {
                type : Function,
                default : () => {}
            }
        },
        data(){
            return {
                value : null
            }
        },
        created() {
            if(this.data.fieldName === ''){
                //加载完成后, 生成表单字段
                this.data.fieldName = 'radio_' + Date.now();
            }
        },
    }
</script>